﻿package ui.control
{
    import flash.net.navigateToURL;
    import flash.net.URLRequest;
    import flash.events.MouseEvent;
   
    public class WebLink extends Button
    {
        /** Button can contain link, but navigate 
          to resource not do**/
        public var uri: String;
        
        
        /** Constructor
         * @param caption text on buttonMode
         * @param autoSize ability change widht and heithgt parameter of buttonMode
         * @param w width
         * @param h height
         */
        public function WebLink(caption:String = "", autoSize:Boolean=true, w:Number=DEFAULT_WIDTH, h:Number=DEFAULT_HEIGHT)
        {
            super(caption, autoSize, w, h);
            reactArea.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
        }
        
        private function mouseDownHandler(event:MouseEvent):void
        {
            navigateToURL(new URLRequest(uri));
        }
    }
}